/*
 *
 *  Copyright (C) 2010 Tal Eisenberg
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package tal.drivechain.plugin;

/**
 *
 * @author Main
 */
public enum Channel {
    CHAIN("chain", 0),
    SETVAR("globalset", 1),
    GLOBALMESSAGE("globalmsg", 2);
    
    String name; int id;
    Channel(String name, int id) {
        this.id = id;
        this.name = name;
    }
    
    public String getName() { return name; }
    public int getId() { return id; }
    public static Channel findChannel(String name) {
        for (Channel channel : Channel.values())
            if (channel.getName().equals(name))
                return channel;
        
        throw new IllegalArgumentException("Unknown channel type: " + name);
    }
    
    public static Channel findChannel(int id) {
        for (Channel channel : Channel.values()) 
            if (channel.getId()==id)
                return channel;
        throw new IllegalArgumentException("Unknown channel id: " + id);
    }
}
